package org.carpediem.conman.entity;

import javax.persistence.*;
import java.net.URI;

/**
 * @author Mark Petrovic
 */
@Entity
public class Document extends DomainObject {
    public final static String ORIGINAL_NAME = "originalName";

    private long id;
    private URI uri;
    private String mimeType;
    private String originalName;
    private String hexMD5;
    private Contact contact;
    private int type;
    private byte[] buffer;
    private boolean persistedToS3 = false;

    @Id
    @GeneratedValue
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @ManyToOne
    @JoinColumn(name = "contact_id")
    public Contact getContact() {
        return contact;
    }

    public void setContact(Contact contact) {
        this.contact = contact;
    }

    @Column(nullable = false)
    public URI getUri() {
        return uri;
    }

    public void setUri(URI uri) {
        this.uri = uri;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getMimeType() {
        return mimeType;
    }

    public void setMimeType(String mimeType) {
        this.mimeType = mimeType;
    }

    public String getOriginalName() {
        return originalName;
    }

    public void setOriginalName(String originalName) {
        this.originalName = originalName;
    }

    @Transient
    public byte[] getBuffer() {
        return buffer;
    }

    public void setBuffer(byte[] buffer) {
        this.buffer = buffer;
    }

    public boolean isPersistedToS3() {
        return persistedToS3;
    }

    public void setPersistedToS3(boolean persistedToS3) {
        this.persistedToS3 = persistedToS3;
    }

    public String getHexMD5() {
        return hexMD5;
    }

    public void setHexMD5(String hexMD5) {
        this.hexMD5 = hexMD5;
    }
}
